package com.ubing.boot.notesforjava.test.optional;

import com.ubing.boot.notesforjava.domel.entity.UserInfo;
import org.aspectj.weaver.ast.Var;

import java.util.ArrayList;
import java.util.Optional;
import java.util.stream.Collectors;

public class Toptional {
    public static void main(String[] args) {
        UserInfo userInfo = new UserInfo();
        userInfo.setUserName("ubing");
        userInfo.setUserId("1");
        userInfo.setSex(1);
        Optional<UserInfo> userInfoOptional = Optional.ofNullable(userInfo);
        userInfoOptional.ifPresent(System.out::println);
        userInfoOptional.ifPresent(item->{});
        ArrayList<UserInfo> userInfos = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            UserInfo user = new UserInfo();
            user.setUserName(i+"ubing");
            user.setUserId(i+"1");
            user.setSex(i);
            userInfos.add(user);
        }
        System.out.println(userInfos);
        System.out.println(userInfos.stream().filter(item -> item.getUserName() == "1ubing").collect(Collectors.toList()));
    }

}
